home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / tools / profiler / prf / prfifl.asm < prev    next >
Encoding:
Assembly Source File  |  1988-11-18  |  2.0 KB  |  80 lines

  1. ;        
  2.         page        59, 80
  3.         title        prfifl.asm
  4.         .286c
  5.  
  6. ; Interface library for PRF (Profiling Tool)
  7.  
  8. ;
  9. ; Equates relevant to cmacros.inc
  10. ;                        
  11.         .sall
  12. ?PLM        equ        0        ;C calling convention
  13. ?WIN        equ        0        ;not MS-Windows
  14.  
  15.         .xlist
  16.         include        cmacros.inc
  17.         .list                           
  18.         .lall
  19.  
  20. sBegin        CODE
  21. assumes        CS, CODE    
  22.             
  23. ;
  24. ; PRF_IsInstalled():
  25. ; Look for the string 'PRF' in the three bytes just before the interrupt
  26. ; handler address.  If the PRF is present these bytes will be set to the 
  27. ; string 'PRF', the PRF_Fn() routine will be informed of the interrupt
  28. ; to use and a non-zero value will be returned.  Otherwise, zero will be
  29. ; returned.
  30. ;
  31.  
  32. cProc        PRF_IsInstalled, <FAR, PUBLIC>, <si,di,es,bx>
  33. ParmW        Interrupt
  34. cBegin        
  35.         mov    si, Interrupt        ;get interrupt number
  36.         shl    si, 1
  37.         shl    si, 1            ;make into vector pointer
  38.         xor    ax, ax            ;will be segment zero
  39.         mov    es, ax            ;use ES
  40.         mov    bx, es:[si]        ;get offset part
  41.         mov    ax, es:2[si]        ;get segment part
  42.         mov    es, ax            ;PRF code segment
  43.         cmp    byte ptr es:[bx-11], 'P';check if first byte of "PRF"
  44.         jne    short NotInstalled1    ;not installed, then jump
  45.         cmp    byte ptr es:[bx-10], 'R';check if second byte of "PRF"
  46.         jne    short NotInstalled1    ;not installed, then jump
  47.         cmp    byte ptr es:[bx-9], 'F'    ;check if third byte of "PRF"
  48.         jne    short NotInstalled1    ;not installed, then jump
  49. ;
  50. ; The PRF is present, link to it by setting the interrupt instruction
  51. ; used by PRF_Fn() to use the correct interrupt.
  52. ;
  53.  
  54.         mov    bx, offset Instruction1+1;address of int instruction
  55.         mov    al, byte ptr (Interrupt);get interrupt number
  56.         mov    byte ptr cs:[bx], al    ;set interrupt instruction
  57.         mov    ax, 1            ;Ok, return value N.Z.
  58.         jmp    short GoBack1
  59.  
  60. NotInstalled1:    xor    ax, ax            ;Not Ok, return value Z.
  61.  
  62. GoBack1:        
  63.                     
  64. cEnd
  65.  
  66. cProc        PRF_Fn, <FAR, PUBLIC>, <>
  67. ParmW        FunctionCode
  68. cBegin
  69. Instruction1:    int        22h        ;Program terminate.
  70.                         ;This will be executed if
  71.                         ;the PRF_IsInstalled() function
  72.                         ;is not used before attempting
  73.                         ;to access PRF functions.
  74. cEnd
  75.  
  76. sEnd
  77.  
  78.         end
  79.  
  80.